//: Playground - noun: a place where people can play

import UIKit

var str = "Hello, playground"

var str1: Int?
str1 = 12

let userInput:String = "12.12345678"
var userInt:Double? = Double(userInput)


class BaseClass{
    var Name: String?
    var Age: Int?
    init() {
        self.Name = "zmj"
        self.Age = 27
    }
}
/**
 *  @author zmj, 16-01-10 22:01:37
 *
 *  协议（基协议）
 */
protocol Action{
    var myName:String{
        get set
    }
    var myAge :Int{
        get
    }
    func getMyName() -> String
}

protocol ChildAction:Action{
    func getMyAge() -> Int
}

class InvokeAction:BaseClass, ChildAction {
    var m_name: String = ""
    var myName: String {
        get {
            return "sundy"
        }set{
            m_name = newValue
        }
    }
    
    var myAge: Int {
        get {
            return 32
        }
    }
    func getMyName() -> String {
        return "My name is \(myName)"
    }
    
    func getMyAge() -> Int {
        return myAge
    }
}

var zmjProtocol: Action = InvokeAction()
zmjProtocol.getMyName()
zmjProtocol.myAge

var wjlProtocol: ChildAction = InvokeAction()
wjlProtocol.getMyAge()
wjlProtocol.getMyName()

func hello(s:protocol<Action, ChildAction>){
    print(s.getMyName(), s.getMyAge(), s.myAge, s.myName)
}

hello(wjlProtocol)


/**
 *  @author zmj, 16-01-10 22:01:05
 *
 *  泛型
 */

func swapValue<T> (inout a:T, inout b:T) {
    let temp = a
    a = b
    b = temp
}

var a = 12
var b = 13
swap(&a, &b)

class Zmj<T> {
    func getName (s: T) {
        print(s)
    }
}

var vzmjClass = Zmj<String>()
print(vzmjClass.getName("1345"))

//swift大会
/*
 1.包涵卿
 */
let nums = [1, 2, 3, 4, 5, 6, 7]

var strs = [String]()
for num in nums {
    strs.append(String(num))
}

print(strs)
let strs1 = nums.map(String.init)
print(strs1)

/*
 2.傅若愚
 */
var someArray :[Int]?
someArray = [1, 2, 3]
var result = someArray.map( {"No. \($0)"} )
print(result)

var dictionary:[String: String?] = [:]
dictionary = ["key":"value"]
func justReturnNil() -> String? {
    return nil
}

dictionary["key"] = justReturnNil()
print(dictionary)

dictionary["key"] = nil
print(dictionary)

Optional<String>.None
Optional<Optional<String>>.None

var arr = [1, 2, 4]
let res = arr.first.flatMap { arr.reduce($0, combine: max) }
print(res)

var cc:Int = 5
let arr1 = [1, 3, 2, 5, cc]
let brr = arr1.map{ $0 * 2 }
let crr = arr1.flatMap{ $0 * 2 }
print(brr, crr)


//枚举，类，结构体
//swift中的枚举和结构体与类非常相似，可以包含类型，实例属性和方法
//swift中的枚举和结构体是值类型，即在代码中他们是以值赋值方式传递的，相对而言，类是引用类型，即在代码中类是以对象的引用方式传递的
//枚举，结构体和类都支持方法（包括其init()方法）重载以接受不同的参数

enum NetworkConnection {
    case NotConnected
    case WiFi (String, Int)
    case Cellular (Int)
    
    func description() -> String {
        switch self {
        case .NotConnected:
            return "Not Connected"
        case .WiFi(let networkName, let pingTime):
            return "WiFi [\(networkName), \(pingTime)]"
        case .Cellular(let pingTime):
            return "Cellular [\(pingTime)]"
        }
    }
    
    mutating func lostConnection() {
        self = .NotConnected
    }
}

let currentConnection1 = NetworkConnection.WiFi("Pocome", 13)
currentConnection1.description()
var currentConnection2 = NetworkConnection.Cellular(14)
currentConnection2.lostConnection()

//类

public enum Sky {
    case Sunny
    case Cloudy
}

public struct WeatherDataPoint {
    public var longitude:   Float
    public var latitude:    Float
    public var sky: Sky
    public var temp: Float
    
    public init (longitude: Float, latitude: Float, sky: Sky, temp: Float) {
        self.longitude = longitude
        self.latitude = latitude
        self.sky = sky
        self.temp = temp
    }
}

public class WeatherService {
    private var simulateCacheHit = true
    public private (set) var dataSourceIdentifier = ""
    
    public init () {}
    
    public func getWeatherFor(longitude: Float, latitude: Float) -> WeatherDataPoint {
        var weatherDataPoint: WeatherDataPoint? = getCachedWeatherFor(longitude, latitude: latitude)
        if let unwrappedWeatherDataPoint = weatherDataPoint {
            return unwrappedWeatherDataPoint
        }
        
        weatherDataPoint = pullWeatherFor(longitude, latitude: latitude)
        if let unwrappedWeatherDataPoint = weatherDataPoint {
            cacheWeatherFor(longitude, latitude: latitude, weatherPointt: unwrappedWeatherDataPoint)
        }
        return weatherDataPoint!
    }
    
    private func pullWeatherFor(longitude: Float, latitude: Float) -> WeatherDataPoint? {
        let pulledweatherDataPoint: WeatherDataPoint? = WeatherDataPoint(longitude: longitude, latitude: latitude, sky: .Cloudy, temp: 10)
        dataSourceIdentifier = "simulatedPull"
        return pulledweatherDataPoint
    }
    
    private func getCachedWeatherFor(longtitude: Float, latitude: Float) -> WeatherDataPoint? {
        let cachedWeatherDataPoint: WeatherDataPoint? = simulateCacheHit ? WeatherDataPoint(longitude: longtitude, latitude: latitude, sky: .Sunny, temp: 30) : nil
        return cachedWeatherDataPoint
    }
    
    private func cacheWeatherFor (longtide: Float, latitude: Float, weatherPointt: WeatherDataPoint) {
        print("\(longtide), \(latitude), \(weatherPointt)")
    }
}

let weatherServieces = WeatherService()
weatherServieces.getWeatherFor(10.17, latitude: 10.20)
weatherServieces.getWeatherFor(10.18, latitude: 10.30)
print("\(weatherServieces.dataSourceIdentifier)")

var optionalSomeValue: String? = "Some"
if var foundString = optionalSomeValue {
    foundString += " found value"
    print("\(foundString)")
}
print(optionalSomeValue)

let optionalInt: Int? = 7
switch optionalInt {
case .None :
    print(".None")
case .Some(let a) where a < 10:
    print("\(a)")
case .Some(10...100):
    print("\(optionalInt!) is between 10 and 100")
default:
    print("\(optionalInt!) is an Int")
}


//可空链表
class Outer {
    var inner: Inner?
}

class Inner {
    var innerInner: InnerInner?
}

class InnerInner {
    var innerMostStr: String?
}

let outerOptional: Outer? = Outer()
if let inMostStr = outerOptional?.inner?.innerInner?.innerMostStr {
    print("This is much nicer \(inMostStr)")
}

var outer02 = Outer()
var innerValue02 = Inner()
var innerInnerValue = InnerInner()
outer02.inner = innerValue02
innerValue02.innerInner = innerInnerValue
//innerInnerValue.innerMostStr = "Inner Most String"
let innerString = outer02.inner?.innerInner?.innerMostStr

//可空链表例2
class Department {
    var departmentName: String?
    var collegeOf: String?
    
    func departmentDescription() -> String? {
        if departmentName != nil {
            return departmentName
        }
        else if collegeOf != nil {
            return collegeOf
        }
        else {
            return nil
        }
    }
}

class SchoolCourse {
    var department: Department?
    let courseName: String
    
    init(name: String) {
        self.courseName = name
    }
    
    func printCourseDescription() {
        if let departmentDes = department?.departmentDescription() {
            print("\(self.courseName) is part of \(departmentDes)")
        }
        else {
            print(self.courseName)
        }
    }
}

class Student {
    var courses = [SchoolCourse]()
    
    //附属属性
    subscript(i: Int) -> SchoolCourse {
        return courses[i]
    }
    
    func numberOfCourse() -> Int {
        return courses.count
    }
    
    func addCourse(c: SchoolCourse) {
        courses.append(c)
    }
}

let student = Student()
student.addCourse((SchoolCourse(name: "math")))
let optionalStudent: Student? = student
let numOfClasses = optionalStudent?.numberOfCourse()
let mathDepartment = Department()
mathDepartment.departmentName = "Math Department"
let mathCourses = SchoolCourse(name: "English")
mathCourses.department = mathDepartment
student.addCourse(mathCourses)
let optionalStudent01: Student? = student
let departmentDescription01 = optionalStudent01?[1].department?.departmentDescription()
if let index = departmentDescription01?.startIndex.advancedBy(10) {
    var subString01 = departmentDescription01?.substringToIndex(index)
    
    if let index2 = departmentDescription01?.startIndex.advancedBy(8, limit: index) {
        var subString02 = departmentDescription01?.substringToIndex(index2)
    }
}

//可空链表，作业2
func findIndexOfCharacter(strArray arr: [String], str: String) -> Int? {
    var index: Int? = nil
    var i = 0
    for str1 in arr {
        if str1.capitalizedString == str.capitalizedString {
            index = i
            break
        }
        i += 1
    }
    return index
}
var strArray01 = ["hello", "miss", "you", "Thank", "Listen", "TO", "How", "ARE", "YOU"]
var strFinde = "How"
findIndexOfCharacter(strArray: strArray01, str: strFinde)

//3.可空链比较
var str001 : String? = "str1"
var str002 : String? = "str2"
if str001 != str002 {
    print("str1 != str2")
}
else {
    print("str1 == str2")
}

//4.遍历文件名,实现GeneratorType协议，注意Element赋类型
class Directory: GeneratorType {
    typealias Element = String
    
    var name : [String]?
    var currentIndex: Int = 0
    init(name: [String]) { self.name = name }
    
    func addSubDirectory(a: String) {
        name?.append(a)
    }
    
    func count() -> Int? {
        return name?.count
    }
    
    func isEmpty() -> Bool {
        if  let isEmpty = self.count() {
            return isEmpty == 0
        }
        return true
    }
    
    subscript(index: Int) -> String? {
        if index >= self.count() || index < 0{
            return nil
        }
        return name?[index]
    }
    
    func next() -> Element? {
        if !(self.isEmpty()) {
            if currentIndex < self.count() {
                if  let next = name?[currentIndex] {
                    currentIndex += 1
                    return next
                }
            }
        }
        return nil
    }
}

var directory01 = Directory(name: ["Today", "Last", "Tommorow"])
var directory02 = Directory(name: ["Listen", "To", "Me", "Miss", "You", "WJL", "ZMJ", "Forever"])
var directory03 = Directory(name: ["Xcode", "File", "Eidt", "View", "Find", "Navigate", "Editor", "Product", "Debug", "Source Control", "Plugins", "Windows", "help"])
print(directory01.next())

var directoryArr001 = [directory01, directory02, directory03]
for direcoty in directoryArr001 {
    while let next = direcoty.next() {
        print(next)
    }
}




func sort (inout array: [Int]) {
    array = array.sort { (lfs: Int, rfs: Int) -> Bool in
        return abs(lfs) < abs(rfs)
    }
}
var numbers = [7, 9, 4, 3, 2, 1, 0, 10, 3, 5];
sort(&numbers)
numbers.append(30)
var number1 = numbers
number1.reduce(0, combine: +)
number1.map({$0 * 2})
number1.sort()
number1.flatMap({$0 * 2})

//模仿reduce编写数组倒序泛型函数
func foldLeft<T, U>(array: [T], initialValue: U, closure: (U, T) -> U) -> U {
    var folderValue = initialValue
    for e in array {
        folderValue = closure(folderValue, e)
    }
    return folderValue
}

func foldRight<T, U>(array: [T], initialValue: U, closure: (T, U) -> U) -> U {
    var folderValue = initialValue
    let reversed = array.reverse()
    for e in reversed {
        folderValue = closure(e, folderValue)
    }
    return folderValue
}

var doubles = [1.0, 2.0, 3.0, 4.0, 1.5, 2.7, 1.1, 0.3]
print(foldLeft(doubles, initialValue: 0.0, closure: +))
print(foldRight(doubles, initialValue: 0.0, closure: +))
print(foldLeft(doubles, initialValue: 1.6, closure: /))
print(foldRight(doubles, initialValue: 1.7, closure: /))

func average(array: [Double]) -> Double {
    return foldLeft(array, initialValue: 0.0, closure: +) / foldLeft(array, initialValue: 0.0, closure: {sum, _ in sum + 1} )
}

average(doubles)
foldLeft(doubles, initialValue: 0.0, closure: +) / Double(doubles.count)

//伪单例对象
//通过嵌套类型
//类方法中存在静态结构体
class mySoftSingle {
    class var sharedInstance: mySoftSingle {
        struct Statis {
            static var instance = mySoftSingle()
        }
        return Statis.instance
    }
}

var singleObject = mySoftSingle.sharedInstance
print(singleObject)

//dispatch_once
struct Statis {
    static var onceToken: dispatch_once_t = 0
}
dispatch_once(&Statis.onceToken) { 
    print("Give me a ping, Vasili. One ping only, please!")
}

var statis01 = Statis.onceToken

//泛型函数
//实现自定义SequenceType协议方法，注意观察Carousel中两个generate实现不同之处和结果
struct CarouselGenerator<T>: GeneratorType {
    var carousel: Carousel<T>
    var iterations: Int = 0
    var done: Bool      = false
    
    init(carousel: Carousel<T>) {
        self.carousel = Carousel<T>(items: carousel.items, initialPosition: carousel.currentPosition)
    }
    
    mutating func next() -> T? {
        if done {
            preconditionFailure("CarouselGenerator already completed")
        }
        if iterations >= carousel.count {
            done = true
            return nil
        }
        iterations += 1
        return carousel.next()
    }
}

//Sequences和Generators
class Carousel<T>: SequenceType {
    var items = [T]()
    var currentPosition = 0
    
    var count: Int {
        return items.count
    }
    
    var isEmpty: Bool {
        return items.isEmpty
    }
    
    convenience init(items: [T], initialPosition: Int = 0) {
        self.init()
        self.items = items
        currentPosition = initialPosition
    }
    
    func append(item: T) {
        items.append(item)
    }
    
    func next() -> T? {
        if self.isEmpty {
            return nil
        }
        
        let nextItem = self[currentPosition]
        currentPosition = (currentPosition + 1) % self.count
        
        return nextItem
    }
    
    //附属属性
    subscript(position: Int) -> T? {
        if self.isEmpty {
            return nil
        }
        return items[position % self.count]
    }
    
    //MARK: SequenceType协议
    //    func generate() -> IndexingGenerator<Array<T>> {
    //        return items.generate()
    //    }
    func generate() -> CarouselGenerator<T> {
        return CarouselGenerator<T>(carousel: self)
    }
}

var carousel01 = Carousel.init(items: numbers, initialPosition: 0)
for i in carousel01 {
    print("\(i)")
}

var carousel02 = Carousel<String>(items: ["one", "two", "three"])
carousel02.next()
for item in carousel02 {
    print("item = \(item)")
}

//运算符重载
func +=<T> (inout lhs:Carousel<T>, rhs:T) {
    lhs.append(rhs)
}

var carousel03 = Carousel<String>(items: ["think", "ipad", "imac", "macbook"])
carousel03 += "iPhone"

//自定义运算符
infix operator ^^^ {
associativity left
precedence 137
}

func ^^^<T: Comparable>(lhs: T, rhs: T) -> T {
    return max(lhs, rhs)
}

1^^^2

//5.隐式拆箱的可空类型
class Practice05 {
    let name: String
    //如果隐式拆箱为nil，然后直接调用，系统则会报错
    //否则就可以直接进行使用
    let grade: String!
    init(name: String, grade: String?) {
        self.name = name
        if let gradeStr = grade {
            self.grade = gradeStr
        }
        else {
            self.grade = nil
        }
    }
}

let practice05test01 = Practice05(name: "zmj", grade: nil)
let practice05test02 = Practice05(name: "wjl", grade: "5")
if let grade01 = practice05test01.grade {
    print("name = \(practice05test01.name), grade = \(grade01)")
}

if let grade02 = practice05test02.grade {
    print("name = \(practice05test02.name), grade = \(grade02)")
}

print(practice05test02.grade)

//7~10 天气API，获取数据
func weatherDataForCity(city: String, closure: (json: NSDictionary) -> ())  {
    let urlString = "http://api.openweathermap.org/data/2.5/weather?q=" + city
    let url = NSURL(string: urlString)
    
    if url == nil {
        return
    }
    let task = NSURLSession.sharedSession().dataTaskWithURL(url!) {(data, response, error) in
        do {
            let json = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableLeaves) as! NSDictionary
            closure(json: json)
        }
        catch let error as NSError! {
            print(error.description)
        }
    }
    task.resume()
}

let result01 = weatherDataForCity("Chicago") { (json) in
    print(json)
}

//泛型函数学习
//泛型函数练习1`2
protocol Traversable {
    associatedtype Element
    
    var Count: Int { get }
    var first: Element? { get }
    var last:  Element? { get }
    
    mutating func previous() -> Element?
    mutating func next() -> Element?
    mutating func reset()
}

class CarouselPractice<T>{
    var items = [T]()
    var currentPosition = 0
    
    var isEmpty: Bool {
        return items.isEmpty
    }
    
    func append(item: T)  {
        items.append(item)
    }
    
    subscript(position: Int) -> T? {
        if self.isEmpty {
            return nil
        }
        return items[position % self.Count]
    }
}

extension CarouselPractice: Traversable {
    typealias Element = T
    var Count: Int {
        return items.count
    }
    
    var first: Element? {
        if self.isEmpty {
            return nil
        }
        return self[0]
    }
    
    var last: Element? {
        if self.isEmpty {
            return nil
        }
        return self[self.Count - 1]
    }
    
    func previous() -> Element? {
        if self.isEmpty {
            return nil
        }
        currentPosition = (currentPosition == 0) ? self.Count - 1 : (currentPosition - 1) % self.Count
        return self[currentPosition]
    }
    
    func next() -> Element? {
        if self.isEmpty {
            return nil
        }
        let nextItem = self[currentPosition]
        currentPosition = (currentPosition + 1) % self.Count
        return nextItem
    }
    
    func reset() {
        currentPosition = 0
    }
}

extension CarouselPractice {
    //从数组添加数据到本对象数组中
    func addItemsFromArray(items: [T]) {
        for item in items {
            self.append(item)
        }
    }
    
    //在指定位置插入一个项
    func insertItemAtIndex(index: Int, item: T) -> Bool {
        if index < 0 || index > self.Count {
            return false
        }
        items.insert(item, atIndex: index)
        return true
    }
    
    //移除某一项
    func remove(index: Int) -> Bool {
        if index < 0 || index > self.Count {
            return false
        }
        items.removeAtIndex(index)
        return true
    }
}

extension CarouselPractice {
    //不改变索引位置，就能获取下一项
    func nextWithChangeIndex() -> T? {
        let index = currentPosition + 1
        if index >= self.Count {
            return nil
        }
        return self[index]
    }
}

extension CarouselPractice {
    //检查某项是否在存在数组中,有就找到所在的位置
    func find<T: Traversable, E:Equatable where T.Element == E>(elementToFind:E, source: T) -> Int? {
        var mutableSource = source
        var foundAtIndex: Int? = nil
        mutableSource.reset()
        for i in 0 ..< mutableSource.Count {
            if let nextItem = mutableSource.next() {
                if nextItem == elementToFind {
                    foundAtIndex = i
                    break
                }
            }
        }
        return foundAtIndex
    }
    
    /**
     找到elementToFind在当前对象中的位置
     
     - parameter elementToFind: 要查询的元素
     
     - returns: 位置的OptionalType
     */
    func findIndex <T: Equatable> (elementToFind: T) -> Int? {
        var foundAtIndex: Int? = nil
        
        for i in 0 ..< self.Count {
            if let nextItem = self[i] {
                let thisT = nextItem as! T
                if thisT == elementToFind {
                    foundAtIndex = i
                    break
                }
            }
        }
        return foundAtIndex
    }
}

let carouselPractice = CarouselPractice<Int>()
carouselPractice.append(10)
carouselPractice.append(20)
print(carouselPractice.items)

let carouseTest01 = [1, 14, 8]
let carouseTest02 = (2, 33)
let carouseTest03 = 1
carouselPractice.addItemsFromArray(carouseTest01)
print(carouselPractice.items)

carouselPractice.insertItemAtIndex(carouseTest02.0, item: carouseTest02.1)
print(carouselPractice.items)

if carouselPractice.remove(3) {
    print("remove Index 3 success")
}
//通过传递本身
let foundIndex = carouselPractice.find(8, source: carouselPractice)
//不需要传递本身,但也会将本身重置
let foundIndex02 = carouselPractice.findIndex(8)


carouselPractice.nextWithChangeIndex()
carouselPractice.nextWithChangeIndex()
carouselPractice.next()
carouselPractice.next()
carouselPractice.next()
carouselPractice.next()

//3.创建一个泛型,实现FIFO队列
class FIFO<T> {
    var items = [T]()
    var currentPosition = 0
    
    var count: Int {
        return items.count
    }
    
    init(items: [T]) { self.items = items }
    
    var isEmpty: Bool {
        return items.isEmpty
    }
    
    func append(item: T) {
        items.append(item)
    }
    
    func out() -> T? {
        if self.isEmpty {
            return nil
        }
        let item = self[0]
        items.removeFirst()
        return item
    }
    
    subscript(i: Int) -> T? {
        if i < 0 || i >= self.count {
            return nil
        }
        return items[i % self.count]
    }
}

let fifo01 = FIFO<Int>(items: [0])
fifo01.append(3)
fifo01.append(4)
fifo01.append(5)
fifo01.append(6)
fifo01.append(7)
print(fifo01.items)
let out01 = fifo01.out()
print(fifo01.items)
let out02 = fifo01.out()
print(fifo01.items)
let out03 = fifo01.out()
print(fifo01.items)
fifo01.append(8)
fifo01.append(9)
let out04 = fifo01.out()
fifo01.append(10)

protocol describeProtocol {
    func describe() -> String
}

//:4.双向链表
class Node<T> : describeProtocol{
    var number: T?
    var previous: Node<T>?
    var next:   Node<T>?
    
    init(number: T?, previous: Node<T>?, next: Node<T>?) {
        self.number = number
        self.previous = previous
        self.next = next
    }
    
    convenience init(number: T?) {
        self.init(number: number, previous: nil, next: nil)
    }
    func describe() -> String {
        var s = ""
        if let str = number {
            s = "number = \(str)"
        }
        return s
    }
}

class NodeList<T: Equatable>: describeProtocol{
    var header : Node<T>?   //队列头部位置
    var last: Node<T>?   //队列当前位置
    var length: Int {
        var length = 0
        var thisHeader = header
        while let n = thisHeader {
            length += 1
            thisHeader = n.next
        }
        return length
    }
    
    var isEmpty: Bool {
        return self.length == 0
    }
    
    init(header: Node<T>?) {
        self.header = header
        last = header
    }
    
    //增
    func add(item: Node<T>) {
        if let nowItem = last {
            item.previous = nowItem
            nowItem.next = item
        }
        last = item
        if self.length == 1 {
            header = last
        }
    }
    //删
    func remove(a: T) -> Bool{
        var flag = false
        var thisHeader = header
        while let n = thisHeader {
            if n.number == a {
                n.previous?.next = n.next
                n.next?.previous = n.previous
                flag = true
            }
            thisHeader = n.next
        }
        return flag
    }
    //删除所有
    func removeAll() -> Bool {
        var flag = false
        var length = self.length
        while let n = header {
            n.next?.previous = nil
            header = n.next
            length -= 1
            if length == 0 {
                flag = true
            }
        }
        header = nil
        last = nil
        return flag
    }
    //改
    func update(index: Int, number: T?) {
        if let n = self[index] {
            n.number = number
        }
    }
    //查
    func select(index: Int) -> T?{
        return self[index]?.number
    }
    
    //protocol
    func describe() -> String {
        var lastStr = ""
        var thisHeader = header
        while let n = thisHeader {
            lastStr += n.describe()
            lastStr += "\n"
            thisHeader = n.next
        }
        return lastStr
    }
    
    //附加属性
    subscript(i: Int) -> Node<T>? {
        if i < 0 || i > self.length {
            return nil
        }
        var item: Node<T>? = nil
        var length = 0
        var thisHeader = header
        
        while let n = thisHeader {
            length += 1
            if i < length {
                item = n
                break
            }
            thisHeader = n.next
        }
        return item
    }
}

let node01 = Node<Int>(number: 1)
let node02 = Node<Int>(number: 2)
let node03 = Node<Int>(number: 4)
let node04 = Node<Int>(number: 7)
let node05 = Node<Int>(number: nil)
let nodeList01 = NodeList<Int>(header: node01)
print(nodeList01.describe())
nodeList01.add(node02)
print(nodeList01.describe())
nodeList01.add(node03)
print(nodeList01.describe())
nodeList01.update(2, number: 3)
print(nodeList01.describe())
nodeList01.remove(1)
print(nodeList01.describe())
let select01 = nodeList01.select(1)
nodeList01.removeAll()
print(nodeList01.describe())


